package gateway;

import java.rmi.Naming;
import java.rmi.RemoteException;

import payment.IPaymentMethod;
import dto.MemberPayDTO;

public class Gateway implements IPaymentMethod {
	private static Gateway instance;
	IPaymentMethod ipayment;
	
	private Gateway (String name)throws RemoteException{
		try {
			ipayment = (IPaymentMethod) Naming.lookup(name);
			
			} catch (Exception e){
				e.printStackTrace();
			}
	}
	public static synchronized Gateway getInstance (String name) throws RemoteException{
		if (instance == null){
			instance = new Gateway(name);
		}
		return instance;
	}
	@Override
	public void pay(MemberPayDTO arg0) throws RemoteException{
	
	}

	@Override
	public void addExpected(double arg0) throws RemoteException {
		try {
			ipayment.addExpected(arg0);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}

}
